<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="message" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="u_client_message('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/crm/sale/UnallocatedCustomerDet?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 修改客户信息 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="客户分类" prop="client_class">
              {{message.client_class}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="客户名称 " prop="">
              {{message.client_name}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="责任人" prop="enteredby">
              {{message.enteredby}}
              <el-button @click="popCustomerChargeP('enteredby','enteredby')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="网站地址" prop="client_net">
              {{message.client_net}}
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="form-unit">
        <span class="mvc-title-left"> 额外明细 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="client_remark">
              <el-input type="textarea" v-model="message.client_remark" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="u_client_message('')" type='success' size="mini"><i class='fa fa-check'></i>更新</el-button>
      <el-button @click="gotoPage('/crm/sale/UnallocatedCustomerDet?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
    </el-form>
    <el-dialog :visible.sync="CustomerChargePVisible" append-to-body>
      <CustomerChargeP v-if="CustomerChargePVisible" ref="CustomerChargeP" :popparams="popparams"> </CustomerChargeP>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import CustomerChargeP from "@/views/crm/sale/CustomerChargeP";
  export default {
    name: 'CustomerCustomerUp',
    components: {
      CustomerChargeP,
    },
    props: ['popparams'],
    data() {
      return {
        CustomerChargePVisible: false,
        CustomerChargePValue: null,
        CustomerChargePDesc: null,
        vueparams: this.getVUEParams(""),
        message: {
          client_class: null,
          client_name: null,
          enteredby: null,
          client_net: null,
          client_remark: null,
        },
        loading: false,
        rules: {
          enteredby: [{
            required: true,
            message: "责任人不能为空",
            trigger: 'change',
          }],
        }
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/UnassignedCustomer/customerCustomerUp?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      u_client_message(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/UnassignedCustomer/u_client_message?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/crm/sale/UnallocatedCustomerDet/unallocatedCustomerDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popCustomerChargeP(desc, value) {
        this.CustomerChargePVisible = true;
        this.CustomerChargePDesc = desc;
        this.CustomerChargePValue = value;
      },
      closeCustomerChargeP(value, desc) {
        this.CustomerChargePVisible = false;
        this.$set(this.message, this.CustomerChargePDesc, desc);
        this.$set(this.message, this.CustomerChargePValue, value);
      },
    },
  }
</script>
